<template>
	<view class="wrap">
		<u-navbar :is-back="false" :border-bottom="false" title="消息">
			<view slot="right" style="padding: 0 10px;">
				<u-icon name="more-circle" :size="28" label="聊天"></u-icon>
			</view>
		</u-navbar>

		<u-row gutter="0" style="margin: 0 20rpx;">
			<u-col span="12" align="top">
				<template v-for="(item,index) in msgList">
					<u-row gutter="0" class="msgitem">
						<u-col span="2" text-align="center">
							<template v-if="item.cate.indexOf('sys')>=0">
								<view class="u-badge-wrap" :style="getBg(item.bgColor)">
									<u-avatar :size="50" :src="item.avaraturl"> </u-avatar>
									<u-badge :count="item.count==0?'':item.count" style="position: absolute;"
										size="mini" :offset="[-10,0]" :is-center="false" type="error"></u-badge>
								</view>
							</template>
							<template v-else>
								<view class="u-badge-wrap">
									<u-avatar :src="item.avaraturl" bg-color="#f2f3f5"> </u-avatar>
									<u-badge :count="item.count==0?'':item.count" style="position: absolute;"
										size="mini" :offset="[-10,0]" :is-center="false" type="error"></u-badge>
								</view>
							</template>
						</u-col>
						<u-col span="7">
							<u-row gutter="0" :style="topuserrightbox">
								<u-col span="12" align="top" text-align="left">
									<view>{{item.title}}</view>
								</u-col>
							</u-row>
							<u-row gutter="0" style="padding: 0 0 5px;">
								<u-col span="12" align="top" text-align="left" class="u-line-1 u-font-12 childTitle">
									{{item.subtitle}}
								</u-col>
							</u-row>
						</u-col>
						<u-col span="3" text-align="right">
							<text class="u-font-12 msgdate">{{item.date}}</text>
						</u-col>
					</u-row>
					<!-- <u-gap height="1" bg-color="#bbb"></u-gap> -->
				</template>
			</u-col>
		</u-row>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				topuserrightbox: {
					"width": "100%",
					"padding": "10rpx 0"
				},
				msgList: [{
					count: 3,
					cate: "sysNote",
					title: "系统通知",
					bgColor: "#f9e3be",
					date: "30分钟前",
					subtitle: "快帮主正式版，即将上线！",
					avaraturl: "/static/msgIcon/sysMsg.png"
				}, {
					count: 0,
					cate: "sysAD",
					title: "活动推送",
					bgColor: "#d3e6fd",
					date: "08-20",
					subtitle: "限时注册会员，赶紧前来围观！",
					avaraturl: "/static/msgIcon/sysAD.png"
				}, {
					count: 6,
					cate: "sysTool",
					title: "快帮助手",
					bgColor: "#caf4e0",
					date: "昨天",
					subtitle: "还在为没流量发愁？快速获得人气就在快帮主！",
					avaraturl: "/static/msgIcon/sysTool.png"
				}, {
					count: 36,
					cate: "userInfo",
					title: "豆豆",
					date: "2021-03-06",
					subtitle: "我要换种口味的奶粉！",
					avaraturl: "/static/msgIcon/baby.png"
				}, {
					count: 22,
					cate: "userInfo",
					title: "豆妈",
					date: "2021-07-22",
					subtitle: "豆爸，豆豆好调皮，咋办？",
					avaraturl: "/static/msgIcon/mom.jpg"
				}, {
					count: 14,
					cate: "userInfo",
					title: "豆爸",
					date: "2021-03-14",
					subtitle: "豆豆，你不要调皮，要听妈妈话！",
					avaraturl: "/static/msgIcon/kbz.png"
				}]
			}
		},
		methods: {
			getBg(_bg) {
				let bgcss = {
					"padding": "20rpx 0 0",
					"background": _bg ? _bg : "#f3f4f7"
				};
				return bgcss;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.warp {
		padding: 0 20rpx;
	}

	.u-badge-wrap {
		width: 90rpx;
		height: 90rpx;
		border-radius: 60rpx;
		position: relative;
		margin: auto;
		text-align: center;
	}

	.msgitem {
		width: 100%;
		margin: 30rpx 0;
	}

	.childTitle {
		color: #8f9196;
		letter-spacing: 1px;
	}

	.msgdate {
		color: #8f9196;
		padding: 0 20rpx 0 0;
	}
</style>
